Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Finder Guide /
Chapter 2 - Finder Objects / Object Class Definitions


File

An object of class File can be any file on a disk, including document files, application files, and so on.

PROPERTIES
A file has all the properties defined for object class Item on page 72: Bounds, Comment, Container, Content Space, Creation Date, Disk, Folder, Icon, ID, Information Window, Kind, Label Index, Modification Date, Name, Physical Size, Position, Selected, Size, and Window.

Unlike other items, a file also has these properties:

creator type
A four-character code that indicates the creator type of the application that created the file.
Class: String
Modifiable: Yes
file type
A four-character code that indicates the type of the file.
Class: String
Modifiable: Yes
locked
A Boolean value that indicates whether the file is locked (true) or not (false).
Class:
Boolean
Modifiable: Yes
product version
The version number shown at the top of the information window for the file.
Class: String
Modifiable: No
stationery
A Boolean value that indicates whether the file is a stationery pad (true) or not (false).
Class: Boolean
Modifiable: Yes
version
The version number shown near the middle of the information window for the file.
Class: String
Modifiable: No
ELEMENT CLASSES
None

COMMANDS HANDLED
Clean Up, Copy, Count, Data Size, Delete, Duplicate, Exists, Get, Make, Move, Open, Print, Put Away, Reveal, Select, Sort, Update

DEFAULT VALUE CLASS RETURNED
A reference to a file or, if you use the plural form files, a list of references.

EXAMPLES
This script returns a list of references to the files whose modification dates are greater than a specified date:

tell application "Finder"   files of startup disk whose modification date > ¬
      date "November 18, 1993"end tell
If you save this script as a script application, it copies a new icon to any files whose icons you drop on the script's icon. The script uses the scripting addition command Choose File to ask the user to specify which file's icon is to be copied:

on open x
   tell application "Finder"      choose file with prompt ¬
         "Choose the file whose icon you want to copy:"      set newIcon to icon of the result
      repeat with i in x
         set the icon of i to newIcon
      end repeat
   end tell
end open

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996